home *** CD-ROM | disk | FTP | other *** search
- Path: grouper.Exis.Net!usenet
- From: Chandler Pitcher <pitch@exis.net>
- Newsgroups: comp.lang.c++
- Subject: Problem with Linked Lists
- Date: Tue, 20 Feb 1996 17:10:31 -0500
- Organization: OAKLAND RAIDERS
- Message-ID: <312A46D7.608A@exis.net>
- NNTP-Posting-Host: 45.exis.net
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (Win95; I)
-
- Help!! I'm trying to create a "circular" list that wraps around again from end to
- beginning, but I am having no luck at setting up a head pointer. The function simply reads names
- from a file and puts them in the list, I am using the word "Stop" as a sentinel. Once the
- function is finished, I try to assign the link to the head, but head is following along with
- the current pointer. How do I keep head and current pointing to the same thing in the
- beginning, but then separate thru the rest of the function. struct node*, and node* head are
- assigned in the main.
-
-
- void read_list(node*& head)
- {
- head = new node;
- node *current = head;
- current = head;
- stringtype temp;
- infile>>temp;
- while (strcmp("Stop", temp))
- {
- strcpy(current->name, temp);
- outfile<<current->name<<" is added to the list."<<endl;
- infile>>temp;
- if (!strcmp("Stop", temp))
- current->link = new node;
- };
- current->link = head;
- return;
- };
-
-
- Thanks for any help!! I'm really lost at this point!!!
-
- Chandler Pitcher |
- Virginia Beach, Virginia | O A K L A N D R A I D E R S
- <pitch@exis.net> |
-